import { Controller } from "../../mvc/core/Controller";
import { TaskTrackPanel } from "../view/task/track/TaskTrackPanel";
import { TaskInfo } from "../model/TaskInfo";
import { STask } from "../../../Message/Game/STask";
import { DataEvent } from "../events/DataEvent";
import { GameController } from "../mvc/GameController";
import { NetDispatcher } from "../../mvc/core/NetDispatcher";
import { ServerCommand } from "../mvc/ServerCommand";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { EventName } from "../mvc/EventName";
import { IView } from "../../mvc/interfaces/IView";
import { LayerManager } from "../manager/LayerManager";
type int = number;
//class TaskTrackController
    
    export  class TaskTrackController extends Controller
    {
       

        /* internal  */onTaskListRes(arg1: Array<any>): void
        {
            (view as TaskTrackPanel).myTaskListInit(arg1);
            return;
        }

        /* internal  */onTaskAdd(arg1: TaskInfo): void
        {
            (view as TaskTrackPanel).taskAdd(arg1);
            return;
        }

        /* internal  */onTaskUpdate(arg1: Array<any>): void
        {
            (view as TaskTrackPanel).taskUpdate(arg1);
            return;
        }

        /* internal  */onTaskDel(arg1: STask): void
        {
            (view as TaskTrackPanel).taskDel(arg1.code);
            return;
        }

        /* internal  */onCanGetTaskRefresh(arg1: Array<any>): void
        {
            (view as TaskTrackPanel).acceptTaskRefresh(arg1);
            return;
        }

        /* internal  */onCanGetTaskAdd(arg1: Array<any>): void
        {
            (view as TaskTrackPanel).acceptTaskAdd(arg1);
            return;
        }

        /* internal  */onCanGetTaskDel(arg1: int): void
        {
            (view as TaskTrackPanel).acceptTaskDel(arg1);
            return;
        }

        /* internal  */onTaskGetRes(arg1: Object): void
        {
            (view as TaskTrackPanel).showCurrent();
            return;
        }

        /* internal  */onTrackClick(arg1: DataEvent): void
        {
            GameController.task.onShowOrHideTrack(arg1.data);
            return;
        }

        public onShowOrHideTrack(arg1: Boolean): void
        {
            if (arg1) 
            {
                (view as TaskTrackPanel).showTrack();
            }
            else 
            {
                (view as TaskTrackPanel).hideTrack();
            }
            return;
        }

        public stageResize(): void
        {
            (view as TaskTrackPanel).stageResize();
            return;
        }

        /* internal  */onGuideNPCFind(arg1: DataEvent): void
        {
            var loc1=arg1.data as TaskInfo;
            (view as TaskTrackPanel).guideTips(loc1);
            return;
        }

        /* internal  */onGuideBossFind(arg1: DataEvent): void
        {
            var loc1=arg1.data as TaskInfo;
            (view as TaskTrackPanel).guideTips(loc1);
            return;
        }

        /* internal  */onGuideFly(arg1: DataEvent): void
        {
            var loc1=arg1.data as TaskInfo;
            (view as TaskTrackPanel).guideTips(loc1);
            return;
        }

        /* internal  */onHideGuide(arg1: DataEvent): void
        {
            (view as TaskTrackPanel).guideHide();
            return;
        }

        /* internal  */onTaskTrackShowOrHide(arg1: DataEvent): void
        {
            var loc1=arg1.data as Boolean;
            this.onShowOrHideTrack(loc1);
            GameController.task.onShowOrHideTrack(loc1);
            return;
        }

        /* internal  */onTaskShowOrHide(arg1: DataEvent): void
        {
            var loc1=arg1.data as Boolean;
            if (loc1) 
            {
                (view as TaskTrackPanel).show();
            }
            else 
            {
                (view as TaskTrackPanel).hide();
            }
            return;
        }

        /* internal  */onGuideVipFly(arg1: DataEvent): void
        {
            var loc1=arg1.data as TaskInfo;
            (view as TaskTrackPanel).guideVipFly(loc1);
            return;
        }

        /* internal  */onGuideDailyAct(arg1: DataEvent): void
        {
            var loc1=arg1.data as TaskInfo;
            (view as TaskTrackPanel).guideDailyAct(loc1);
            return;
        }

        /* internal  */onGuideApplyGuild(arg1: DataEvent): void
        {
            var loc1=arg1.data as TaskInfo;
            (view as TaskTrackPanel).guideTips(loc1);
            return;
        }

        /* internal  */onStageResizeF8Handler(arg1: DataEvent): void
        {
            (view as TaskTrackPanel).onStageResizeF8();
            return;
        }

        protected /* override */ initServer(): void
        {
            NetDispatcher.addCmdListener(ServerCommand.TaskListRes, this.onTaskListRes);
            NetDispatcher.addCmdListener(ServerCommand.TaskAdd, this.onTaskAdd);
            NetDispatcher.addCmdListener(ServerCommand.TaskUpdate, this.onTaskUpdate);
            NetDispatcher.addCmdListener(ServerCommand.TaskDel, this.onTaskDel);
            NetDispatcher.addCmdListener(ServerCommand.CanGetListRefresh, this.onCanGetTaskRefresh);
            NetDispatcher.addCmdListener(ServerCommand.CanGetListAdd, this.onCanGetTaskAdd);
            NetDispatcher.addCmdListener(ServerCommand.CanGetListDel, this.onCanGetTaskDel);
            NetDispatcher.addCmdListener(ServerCommand.TaskGetRes, this.onTaskGetRes);
            Dispatcher.addEventListener(EventName.Guide_NPCFind, this.onGuideNPCFind);
            Dispatcher.addEventListener(EventName.Guide_BossFind, this.onGuideBossFind);
            Dispatcher.addEventListener(EventName.Guide_Fly, this.onGuideFly);
            Dispatcher.addEventListener(EventName.Guide_PathHide, this.onHideGuide);
            Dispatcher.addEventListener(EventName.TaskTrackShowOrHide, this.onTaskTrackShowOrHide);
            Dispatcher.addEventListener(EventName.TaskShowOrHide, this.onTaskShowOrHide);
            Dispatcher.addEventListener(EventName.Guide_VIPFly, this.onGuideVipFly);
            Dispatcher.addEventListener(EventName.Guide_DailyAct, this.onGuideDailyAct);
            Dispatcher.addEventListener(EventName.Guide_ApplyGuild, this.onGuideApplyGuild);
            Dispatcher.addEventListener(EventName.StageResizeF8, this.onStageResizeF8Handler);
            return;
        }

        protected /* override */ initView(): IView
        {
            var loc1=null;
            loc1 = new TaskTrackPanel();
            loc1.addEventListener(EventName.TrackClick, this.onTrackClick);
            loc1.layer = LayerManager.uiLayer;
            return loc1;
        }
    }
